package com.nathan.crm.task;

import com.nathan.crm.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *  定时任务的执行
 */
@Component
public class JobTask {

    @Resource
    private CustomerService customerService;

    // 每月执行一次
    @Scheduled(cron = "0 15 10 15 * ?")
    public void job(){
        System.out.println("定时任务执行----->" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

        customerService.updateCustomerState();
    }

}


